Waterloo ACM Programming Contest Fall 2
[and.git] / 11339 - Sonnet Rhyme Verifier / 11339.cpp
blob9190d6cd92f20cc249c07e5e8a217066fffbd625
1 /*
2 C++ no sirve para trabajar con tildes. Que mierda!
3 */
5 #include <iostream>
6 #include <stdlib.h>
7 #include <vector>
8 #include <map>
10 using namespace std;
12 const string minu = "áéíóúñ";
13 const string mayu = "ÁÉÍÓÚÑ";
14 const string tildes = "áéíóúñÁÉÍÓÚÑ";
15 const string bad = " ¡!,.:;¿?-";
17 wchar_t toLower(wchar_t c){
18 int t;
19 if (bad.find(c) != string::npos) return c;
20 if ((t = minu.find(c)) != string::npos){
21 return c;
23 if ((t = mayu.find(c)) != string::npos){
24 return minu[t];
26 return tolower(c);
29 bool isAlpha(wchar_t c){
30 if (bad.find(c) != string::npos) return false;
31 c = toLower(c);
32 if (minu.find(c) != string::npos) return true;
33 return isalpha(c);
36 void clean(string &s){
37 cout << s << endl;
39 int n = s.size();
40 for (int i=0; i<n; ++i){
41 s[i] = toLower(s[i]);
42 if (bad.find(s[i]) != string::npos || (!isAlpha(s[i]) && tildes.find(s[i]) == string::npos)){
43 s.erase(i, 1);
44 --i;
45 n = s.size();
48 if (tolower(s[s.size()-1]) == 's'){
49 s.erase(s.size()-1, 1);
51 cout << s << endl;
54 int main(){
55 string sufijos, line;
56 while (getline(cin, sufijos)){
57 getline(cin, line);
58 //Escribo el titulo
59 cout << line << ": ";
61 vector<string> p;
62 while (getline(cin, line)){
63 clean(line);
64 if (line == "") break;
67 //Check here
69 return 0;